#include "rclcpp/rclcpp.hpp"
#include "geometry_msgs/msg/point_stamped.hpp"
using geometry_msgs::msg::PointStamped;
using namespace std::chrono_literals;
//选择插件PointStamped ，选择话题
class PointTFBroadcaster:public rclcpp::Node
{
public:
    PointTFBroadcaster():Node("point_tf_broadcaster_node")
    {
        RCLCPP_INFO(this->get_logger(),"点坐标变化发布节点已创建！");
        publisher_=this->create_publisher<PointStamped>("point",10);
        timer_=this->create_wall_timer(1.0s,
        std::bind(&PointTFBroadcaster::get_point_transform,this));
    }
private:    
    void get_point_transform()
    {
        auto ps=PointStamped();
        x+=0.05;
        ps.header.stamp=this->get_clock()->now();
        ps.header.frame_id="laser";
        ps.point.x=x;
        ps.point.y=y;
        ps.point.z=z;
        publisher_->publish(ps);
    }
private:
    std::shared_ptr<rclcpp::Publisher<PointStamped>>publisher_;
    std::shared_ptr<rclcpp::TimerBase>timer_;
    float x=0.0;   
    float y=1.0;   
    float z=1.0;   
};
int main(int argc,char*argv[])
{
    rclcpp::init(argc,argv);
    auto node=std::make_shared<PointTFBroadcaster>();
    rclcpp::spin(node);
    rclcpp::shutdown();
    return 0;
}


